﻿@using NetSurveillance.WebApp.Utilities
@model NetSurveillance.WebApp.DataServices.Models.DataRecordResult
           
@{
    Layout = null;
    var displayFields = ViewBag.DisplayFields;
    var supportFields = ViewBag.SupportFields;
    var checkIds = ViewBag.CheckIds as long[];
}
<tr>
    <td>
        @Html.CheckBox("checkedDataRecordIds", Model.Id, checkIds != null && Model != null && checkIds.Contains(Model.Id))
    </td>
    @foreach (var supportField in supportFields)
    {
        if (ViewUtility.InDisplayFields(displayFields, supportField.PropertyName))
        {
            var displayHtml = Html.Display(supportField.PropertyName as string);
            displayHtml = (Model != null && Model.HitName == supportField.PropertyName) ?
                              MvcHtmlString.Create(string.Format("<div class='hitKeyword'>{0}</div>", displayHtml)) :
                              displayHtml;
            <td class="@supportField.PropertyName" title="@displayHtml">
                @{

                    displayHtml = MvcHtmlString.IsNullOrEmpty(displayHtml) ? MvcHtmlString.Create("无") : displayHtml;
                    if (supportField.PropertyName == "Title" && Model != null && !string.IsNullOrWhiteSpace(Model.FilePath))
                    {
                        <a href="@Url.Action("DownloadFile", "Task", new {drId = Model.Id})">
                            @(displayHtml)
                        </a>
                    }
                    else if (supportField.PropertyName == "Title" && Model != null && Model.DataIMRecordId.HasValue)
                    {
                        <a href="@Url.Action("DataIMRecordList", "Task", new {dataIMRecordId = Model.DataIMRecordId.Value})">
                            @(displayHtml)
                        </a>
                    }
                    else if (supportField.PropertyName == "Url" && Model != null && !string.IsNullOrWhiteSpace(Model.Url))
                    {
                        <a href="@Html.Raw(Model.Url)" target="_blank">
                            @(displayHtml)
                        </a>
                    }
                    else
                    {
                        @displayHtml
                    }
                    if ((supportField.PropertyName == "Title" && Model != null &&
                         (String.Compare(Model.Protocol, "webpost", StringComparison.OrdinalIgnoreCase) == 0 ||
                         string.Compare(Model.Protocol, "http", StringComparison.CurrentCultureIgnoreCase) == 0)) &&
                        Model != null && !string.IsNullOrWhiteSpace(Model.Content))
                    {
                        <input type="button" class="buttonViewContent" data-drId="@Model.Id" value="查看"/>
                    }
                }
            </td>
        }
    }
</tr>